import { SpecialGiftBody } from "./SpecialGiftBody";
import { GBoxDirection } from "../../../../../com/mui/containers/globalVariable/GBoxDirection";
import { GScrollPane } from "../../../../../com/mui/controls/GScrollPane";
import { ScrollPolicy } from "../../../../../fl/controls/ScrollPolicy";
import { ObjectPool } from "../../../../../com/gengine/utils/pools/ObjectPool";
import { SpecialGiftItem } from "./SpecialGiftItem";
type int = number;
//class SpecialGiftPanel
    
    export  class SpecialGiftPanel /* flash.display.Sprite */
    {
        constructor(arg1: int, arg2: int)
        {
            
            this._width = arg1;
            this._height = arg2;
            this.initUI();
            return;
        }

        protected initUI(): void
        {
            this._body = new SpecialGiftBody();
            this._body.verticalGap = 2;
            this._body.direction = GBoxDirection.VERTICAL;
            this._scrollPane = new GScrollPane();
            this._scrollPane.width = this.width;
            this._scrollPane.height = this.height;
            this._scrollPane.styleName = "GScrollPane";
            this._scrollPane.verticalScrollPolicy = ScrollPolicy.ON;
            this._scrollPane.horizontalScrollPolicy = ScrollPolicy.OFF;
            this._scrollPane.source = this._body;
            this._scrollPane.scrollDrag = false;
            this._scrollPane.focusEnabled = false;
            addChild(this._scrollPane);
            return;
        }

        public updateData(arg1: Array<any>): void
        {
            var loc1=0;
            var loc3=null;
            var loc4=null;
            this.dispose();
            var loc2=arg1.length;
            while (loc1 < loc2) 
            {
                loc4 = arg1[loc1];
                (loc3 = ObjectPool.getObject(SpecialGiftItem)).updateData(loc4);
                this._body.addChild(loc3);
                ++loc1;
            }
            this._body.invalidate();
            this._scrollPane.refreshPane();
            this._scrollPane.update();
            this._scrollPane.verticalScrollPosition = 0;
            return;
        }

        public dispose(): void
        {
            var loc1=null;
            while (this._body.numChildren > 0) 
            {
                loc1 = this._body.removeChildAt(0) as SpecialGiftItem;
                loc1.dispose();
                ObjectPool.disposeObject(loc1);
            }
            return;
        }

        public /* override */ get height(): number
        {
            return this._height;
        }

        public /* override */ get width(): number
        {
            return this._width;
        }

        protected /* var */_width: int;

        protected /* var */_height: int;

        protected /* var */_body: SpecialGiftBody;

        protected /* var */_scrollPane: GScrollPane;
    }
